<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<sapn id="clock">00:00:00</sapn>
				
		<script>
			function time(){
				var d = new Date(),
					h,m,s = d.getSeconds();
					clock = document.getElementById('clock');	
					
					
				var times = function(){					                                           
					h = d.getHours();
					m = d.getMinutes();
					s = d.getSeconds();					
					clock.innerHTML = fill(h) +':'+ fill(m) +':' + fill(s);
					d.setSeconds(++s);
				};
				times();
				setInterval(times,1000);				
			};
			
			
			var fill = function(num) {
				/*if(num<10){ 
					return '0' + num;
				}else{
					return num;
				};*/
				return num < 10 ? '0' + num : num; //三元表达式
			};
			time();
		</script>
	</body>
</html>
